package com.ssm.service.impl;

import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.ssm.mapper.ItemsMapper;
import com.ssm.mapper.ItemsMapperCustom;
import com.ssm.po.Items;
import com.ssm.po.ItemsCustom;
import com.ssm.po.ItemsQueryVo;
import com.ssm.service.ItemsService;

public class ItemsServiceImpl implements ItemsService {
	
	@Autowired
	private ItemsMapperCustom itemsMapperCustom;
	
	@Autowired
	private ItemsMapper itemsMapper;
	
	
	@Override
	public List<ItemsCustom> findItemList(ItemsQueryVo itemsQueryVo) throws Exception {
		
		List<ItemsCustom> list = itemsMapperCustom.findItemList(itemsQueryVo);
		
		return list;
	}
	
	@Override
	public ItemsCustom selectItemsById(int id) throws Exception {
		
		Items items = itemsMapper.selectByPrimaryKey(id);
		
		ItemsCustom itemsCutom = new ItemsCustom();
		System.out.println(itemsCutom.getItemsId());
		BeanUtils.copyProperties(items, itemsCutom);
		
		return itemsCutom;
	}

	@Override
	public boolean updateItems(Integer id, ItemsCustom itemsCustom) throws Exception {
		
		itemsCustom.setItemsId(id);
		int result = itemsMapper.updateByPrimaryKey(itemsCustom);
		if(result>0){
			return true;
		}
		return false;
	}

}
